package defenses;

/**
 * Calculating defenses
 * 
 * @author bjo013
 * 
 */
public class Defenses
{
	int[] AC;
	int[] Fort;
	int[] Ref;
	int[] Will;

	/**
	 * Constructor for defenses
	 * 
	 * @param AC
	 *            AC
	 * @param Fort
	 *            fortitude save
	 * @param Ref
	 *            reflex save
	 * @param Will
	 *            will save
	 */
	public Defenses(int[] AC, int[] Fort, int[] Ref, int[] Will)
	{
		this.AC = AC;
		this.Fort = Fort;
		this.Ref = Ref;
		this.Will = Will;
	}

	/**
	 * returns the AC
	 * 
	 * @return the collected AC
	 */
	public int getAC()
	{
		return getDefense(AC);
	}

	/**
	 * returns the fortitude
	 * 
	 * @return the collected fortitude
	 */
	public int getFort()
	{
		return getDefense(Fort);
	}

	/**
	 * returns the reflex
	 * 
	 * @return the collected reflex save
	 */
	public int getRef()
	{
		return getDefense(Ref);
	}

	/**
	 * returns the will
	 * 
	 * @return the collected will save
	 */
	public int getWill()
	{
		return getDefense(Will);
	}

	private int getDefense(int[] defense)
	{
		int j = 0;
		for (int i : defense)
		{
			j = j + i;
		}
		return j;
	}

	@Override
	public String toString()
	{
		String s = new String();
		s += "AC: " + getAC() + "\n";
		s += "Fort: " + getFort() + "\n";
		s += "Ref: " + getRef() + "\n";
		s += "Will: " + getWill();
		return s;
	}
}
